#ifndef __HDRDEMO_UTILS_HPP__
#define __HDRDEMO_UTILS_HPP__

#include <string>
#include "Extensions/ExtensionsLoader.hpp"

class ProjectionMatrix;

namespace HDRDemoUtils
{
	/*
	 * Reads file into container.
	 * @param pTexContainer is a pointer to STL string instance already created.
	 * @param fileName is a name of a file to read.
	 * @return indicates success or failure.
	 */
	bool readTextFile(std::string* pTextContainer, std::string fileName);

	/*
	 * Assigns texture to shader.
	 * @param shader is a shader handle.
	 * @param texName is a name of texture as it will be used inside shader.
	 * @param iTexID is an OpenGL ID of texture created during call to glGenTextures.
	 * @return indicates success or failure.
	 */
	bool textureForShader(const GLhandleARB& shader, std::string texName, const int& iTexID);

	/*
	 * Assigns projection matrix to shader.
	 * @param shader is a shader handle.
	 * @param matrixName is a name of matrix as it will be used inside shader.
	 * @param pProjMatrix is a pointer to ProjectionMatrix object storing appropriate data.
	 * @return indicates success or failure.
	 */
	bool projMatrixForShader(const GLhandleARB& shader, std::string matrixName, ProjectionMatrix* pProjMatrix);

	/*
	 * Generates one dimmensional array of three dimmensional vectors.
	 * @param ppRandVectors is a pointer to where memory for array should be allocated. User is responsible for deletion fo this array.
	 * @param iVecCount is a number of vectors to be created.
	 * @param bOptimizeForTex determines if additional computations allowing use of vectors as texture data should be performed.
	 * @return indicates success or failure.
	 */
	bool genRandomVectors3D(float** ppRandVectors, const unsigned int& iVecCount, bool bOptimizeForTex = false);

	/*
	 * Creates texture and copies lights data into it.
	 * @param pLights pointer to array containing lights data.
	 * @param iLightsCount is a number of lights stored under pLights.
	 * @param pTexID is a variable to receive texture ID.
	 * @return indicates success or failure.
	 */
	bool lights2Texture(float* pLights, const unsigned int& iLightsCount, GLuint* pTexID);

	/*
	 * Finds optimal width and height for power 2 texture with given total number of texels.
	 * Function will also create two uniform variables to be used in shader's loop. 
	 * First one will hold information about ...
	 * @param iTotalSize is a total number of texels.
	 * @param pOptWidth is variable where optimal texture width will be stored.
	 * @param pOptHeight is variable where optimal texture height will be stored.
	 */
	void findOptimalPower2Size(const int& iTotalSize, int* pOptWidth, int* pOptHeight);
}

#endif //__HDRDEMO_UTILS_HPP__

//EOF
